import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;

public class ETL {

    private static void buildTable(String tableQuery, Connection conn)
            throws Exception {

        Statement stmt = null;
        stmt = conn.createStatement();
        stmt.execute(tableQuery);

        /**
         * String sql = "INSERT INTO  _retweet( status_id, status_date, " +
         * "retweet_by_user_id, retweet_by_user_name, retweet_by_user_name_lowercase, "
         * +
         * "retweet_of_user_id, retweet_of_user_name, retweet_of_user_name_lowercase) "
         * +
         * 
         * " VALUES(" + status_id + ", '" + status_date + "', " + user_id +
         * ", '" + user_name + "', '" + user_name_lowcase + "', " +
         * (retweet_of_user_id==-1? "null" : retweet_of_user_id ) + ", '" +
         * retweet_of_user_name + "', '" + retweet_of_user_name_lowercase + "'"
         * + ");";
         */

    }

    public static void main(String[] args) throws Exception {
        long s = System.currentTimeMillis();
        System.out.println("Start Time: " + new Date());

        Connection con = DriverManager.getConnection(
                "jdbc:mysql://localhost/DATABASE_NAME", "root", "rootpassword");

        String tableQuery = "CREATE TABLE `movie` ( "
                + "`m_id` int(11) NOT NULL auto_increment,"
                + "`name` varchar(20) NOT NULL,"
                + "`year` int(4) NOT NULL,"
                + "`genre` varchar(10) NOT NULL,"
                + "`d_id` int(11) NOT NULL,"
                + "`IMDB_rate` float(3) NOT NULL,"
                + "`group_rate_avg` float(3) default NULL,"
                + "`group_rate_count` int(6) default NULL,"
                + "PRIMARY KEY  (`m_id`),"
                + "FOREIGN KEY (`d_id`)"
                + "KEY `name` (`name`),"
                + "KEY `status_date` (`status_date`),"
                + "KEY `year` (`year`),"
                + "KEY `genre` (`genre`),"
                + "KEY `IMDB_rate` (`IMDB_rate`),"
                + "KEY `group_rate_avg` (`group_rate_avg`),"
                + "KEY `group_rate_count` (`group_rate_count`)"
                + ") ENGINE=MyISAM AUTO_INCREMENT=10075890 DEFAULT CHARSET=latin1";
        
        buildTable(tableQuery, con);

        con.close();

        System.out.println("Finished Time: " + new Date());
        System.out.println("Finished. Time: "
                + (System.currentTimeMillis() - s) / 1000 + " seconds");
    }
}
